<form action="{:U('finance/add','t=paymentorder')}" method="post">
<input name="payables_id" id="payables_id" type="hidden" value="{$id}" />
	<table class="table table-hover">
		<tfoot>
			<tr>
				<td>&nbsp;</td>
				<td><input name="submit" class="btn btn-primary" type="submit" value="{:L('ADD')}"/> &nbsp; <input class="btn" type="button" onclick="$('#dialog-paymentorder').dialog('close');" value="{:L('CANCEL')}"/></td>
			</tr>
		</tfoot>
		<tbody>
			<tr>
				<th colspan="2">{:L('ADD PAYMENTORDER')}</th>
			</tr>
			<tr>
				<td class="tdleft" width="20%" valign="middle">{:L('PAYMENTS SINGLE NUMBER')}</td>
				<td valign="middle"><input name="name" id="name" class="text-input large-input" type="text" value="{:L('AUTOMATIC_GENERATION')}"/></td>
			</tr>
			<tr>
				<td class="tdleft" width="20%" valign="middle">{:L('OWNER_ROLE')}</td>
				<td valign="middle"><input name="owner_role_id" id="owner_role_id" type="hidden" value="{$Think.session.role_id}"/><input name="owner_name" id="owner_name" class="text-input large-input" type="text" value="{$Think.session.name}"/></td>
			</tr>
			<tr>
				<td class="tdleft" valign="middle">{:L('PAYMENTS')}</td>
				<td valign="middle"><input class="text-input large-input" id="money" name="money" type="text" /></td>
			</tr>
			<tr>
				<td class="tdleft" valign="middle">{:L('PAYMENT TIME')}</td>
				<td valign="middle"><input onclick="WdatePicker()"  type="text" id="pay_time" name="pay_time"/></td>
			</tr>
			<tr>
				<td class="tdleft" valign="middle">{:L('STATUS')}</td>
				<td valign="middle"><input  type="radio" checked="checked" name="status" value="0"/> {:L('NOT CLOSING')} <input type="radio" name="status" value="1"/> {:L('HAS CLOSING')} </td>
			</tr>
			<tr>
				<td class="tdleft" valign="middle">{:L('DESCRIPTION')}</td>
				<td valign="middle"><textarea class="span6" rows="6" name="description"></textarea></td>
			</tr>
		</tbody>
	</table>
</form>
<div id="dialog-message2" title="{:L('SELECT THE LEADER')}">loading...</div>
<script type="text/javascript">
<if condition="C('ismobile') eq 1">width=$('.container').width() * 0.9;<else />width=800;</if>
$("#dialog-message2").dialog({
	autoOpen: false,
	modal: true,
	width: width,
	maxHeight: 400,
	buttons: {
		"Ok": function () {
			var item = $('input:radio[name="owner"]:checked').val();
			var name = $('input:radio[name="owner"]:checked').parent().next().html();
			if(item){
				$('#owner_name').val(name);
				$('#owner_role_id').val(item);
			}
			$(this).dialog("close");
		},
		"Cancel": function () {
			$(this).dialog("close");
		}
	},
	position: ["center", 100]
});
$(function(){
	$("#owner_name").click(
		function(){
			$('#dialog-message2').dialog('open');
			$('#dialog-message2').load('{:U("user/listDialog","by=all")}');
		}
	);
});

$(document).ready(function(){
	$("#money").blur(function(){
		var total = parseInt({$payables['price']});
		var payables_money = parseInt({$payables_money});
		var money = parseInt($('#money').val());
		if( (money + payables_money) > total){
			alert('{:L('EXCEED THE AMOUNT')}');
		}
	});
});
</script>